package com.ewili.x.special.controller.admin;

import com.ewili.framework.param.Response;
import com.ewili.x.special.entity.User;
import com.ewili.x.special.service.data.inter.UserService;
import com.ewili.x.special.vo.AdminLoginRequest;
import com.ewili.x.special.vo.UserResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "管理员操作用户的api")
@RestController
@RequestMapping("/admin/user")
public class UserController {

    @Autowired
    private UserService userService;

    public Response login(@Valid AdminLoginRequest request) {
        return null;
    }

    @ApiOperation("查询所有用户")
    @RequestMapping("/findUsers")
    @ResponseBody
    public Response findUsers(Pageable pageable) {
        Page<User> users = userService.findAll(pageable);
        UserResponse response = new UserResponse();
        response.setUsers(users);
        return response;
    }
}
